Skip to content

fix(storage): create evidence/ dir on demand in put_evidence#498

Open
plind-junior wants to merge 3 commits into
testfrom
feat/passive-answer-memory
Open

fix(storage): create evidence/ dir on demand in put_evidence#498
plind-junior wants to merge 3 commits into
testfrom
feat/passive-answer-memory

Conversation

@plind-junior

@plind-junior plind-junior commented Jul 16, 2026

Copy link
Copy Markdown
Member

receipt-backed capture wrote the source but silently filed 0 claims on any KB created before receipts existed: put_evidence opened evidence/.yaml with mode "x" but never made the evidence/ dir, so the write threw FileNotFoundError and capture_answer's cli wrapper swallowed it (source written, no claims, no error). mkdir(parents=True, exist_ok=True) first, the way put_source already does. fresh vouch init created evidence/ so this only bit pre-existing kbs.

regression test covers put_evidence on a kb whose evidence/ dir is absent.

What changed

Why

What might break

VEP

Tests

  • make check passes locally (lint + mypy + pytest)
  • New / changed behaviour has a test
  • CHANGELOG.md updated under ## [Unreleased]

Summary by CodeRabbit

  • Bug Fixes

    • Fixed evidence receipt creation for knowledge bases missing the evidence directory.
    • Evidence files are now saved successfully when using older or previously migrated knowledge bases.
  • Tests

    • Added regression coverage to verify the evidence directory is recreated automatically.

receipt-backed capture wrote the source but silently filed 0 claims on any KB
created before receipts existed: put_evidence opened evidence/<id>.yaml with
mode "x" but never made the evidence/ dir, so the write threw FileNotFoundError
and capture_answer's cli wrapper swallowed it (source written, no claims, no
error). mkdir(parents=True, exist_ok=True) first, the way put_source already
does. fresh `vouch init` created evidence/ so this only bit pre-existing kbs.

regression test covers put_evidence on a kb whose evidence/ dir is absent.
@plind-junior
plind-junior changed the base branch from main to test July 16, 2026 01:41
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: c11964c3-e675-4524-800e-5e60b550275d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

KBStore.put_evidence now creates the missing evidence/ directory before writing receipts. A regression test removes the directory, writes evidence, and verifies the expected YAML file is recreated.

Changes

Evidence storage

Layer / File(s) Summary
Create evidence directory before receipt write
src/vouch/storage.py, tests/test_storage.py
put_evidence creates the evidence directory on demand, and the regression test verifies successful evidence YAML creation after the directory is removed.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Suggested reviewers: dripsmvcp, galuis116

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: creating the evidence directory on demand in put_evidence.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/passive-answer-memory

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added storage kb storage, migrations, schemas, and proposals tests tests and fixtures size: XS less than 50 changed non-doc lines labels Jul 16, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/test_storage.py`:
- Around line 644-647: Update the evidence-directory setup in the test around
store.put_evidence to ensure shutil.rmtree removes the directory without
ignore_errors=True, or explicitly assert the directory is absent before invoking
put_evidence. Preserve the existing assertion that the evidence YAML file is
recreated successfully.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f52a4320-3da2-40a0-96fe-1fd3ae06f26b

📥 Commits

Reviewing files that changed from the base of the PR and between 3d9e62b and 5f8add2.

📒 Files selected for processing (2)
  • src/vouch/storage.py
  • tests/test_storage.py

Comment thread tests/test_storage.py
Comment on lines +644 to +647
shutil.rmtree(store.kb_dir / "evidence", ignore_errors=True)
ev = store.put_evidence(Evidence(id="e1", source_id=src.id,
locator="L1-L5", quote="snippet"))
assert (store.kb_dir / "evidence" / f"{ev.id}.yaml").exists()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Do not ignore failure to remove the evidence directory.

ignore_errors=True can leave evidence/ present, allowing this regression test to pass without exercising the missing-directory path. Remove the directory without suppressing errors, or assert that it no longer exists before calling put_evidence.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_storage.py` around lines 644 - 647, Update the evidence-directory
setup in the test around store.put_evidence to ensure shutil.rmtree removes the
directory without ignore_errors=True, or explicitly assert the directory is
absent before invoking put_evidence. Preserve the existing assertion that the
evidence YAML file is recreated successfully.

@plind-junior plind-junior added the auto-pr auto-pr orchestration label Jul 16, 2026
capture_answer used to file a pending claim per answer when no auto-approve gate
was set, which floods the review queue on every substantive turn once the Stop
hook is installed. now it returns `gate-closed` and writes nothing unless
review.auto_approve_on_receipt or approver_role: trusted-agent is set — the gate
is the on-switch, so `install-mcp` is safe for anyone who has not opted into
passive memory. the gated session-rollup path is unaffected.
add a "Passive memory" section: the two-step enable (install-mcp wires the Stop
answer-capture + per-prompt recall hooks; set review.auto_approve_on_receipt, or
approver_role: trusted-agent, to open the gate), how it behaves (saves per
answer not on tab-close, recalled next session), and honest caveats — it
captures every substantive answer, recall is injected not enforced (use
`vouch synthesize` / `/vouch-ask` for a guaranteed grounded answer), short and
duplicate answers are skipped. also correct the install-mcp hook list, which
had drifted to three hooks.
@github-actions github-actions Bot added docs documentation, specs, examples, and repo guidance size: S 50-199 changed non-doc lines and removed auto-pr auto-pr orchestration size: XS less than 50 changed non-doc lines labels Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs documentation, specs, examples, and repo guidance size: S 50-199 changed non-doc lines storage kb storage, migrations, schemas, and proposals tests tests and fixtures

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant